/**
 * just test for the containers
 * */
#include "container_util.h"

bool compare(pair<int, double> a, pair<int, double> b) {
	return a.first < b.first;
}


int main() {
	const int n = 10077090;
	int* key = new int[n];
	double* value = new double[n];
	for(int i = 0; i < n; i++) {
		key[i] = rand()%(32*1024);
		value[i] = rand()/(double)RAND_MAX;
	}
	vector<pair<int, double> > gold;
	for(int i = 0; i < n; i++) {
		gold.push_back(pair<int, double>(key[i], value[i]));
	}

	INIT_TIMER;

	/*gold sorting algorithm*/
	START_TIMER;
	stable_sort(gold.begin(), gold.end(), compare);	
	END_TIMER;
	PRINT_TIMER_SEC("gold sorting");

	/*counting sort*/
	START_TIMER;
	counting_sort2(key, value, n);	
	END_TIMER;
	PRINT_TIMER_SEC("count sorting");
		
	/*check result*/
	for(int i = 0; i < n; i++) {
		if(key[i] != gold[i].first) {
			cout << "!!!key error" << endl;
		}
		if(value[i] != gold[i].second) {
			cout << "!!!value error" << endl;
		}
	}
	cout << "Test done." << endl;

	return EXIT_SUCCESS;
}

